{% extends "base.html" %}

{% block content %}
    {%if item %}
        <h2>Редактируем картинку</h2>
    {% else %}
        <h2>Добавляем картинку</h2>
    {% endif %}
    
    <br>
    <form action="/manage/portfolio" method="post" enctype="multipart/form-data">
        
        {%if item %}
            <input type="hidden" name="id" value="{{ item.key.id }}" />
            <a href="/portfolio/image/{{ item.key.id }}/full" title="{{ item.name|escape }}">
                <img src="/portfolio/image/{{ item.key.id }}/thumb" alt="{{ item.name|escape }}">
            </a>
        {% endif %}
        
        <input type="hidden" name="action" value="{{ action|escape }}" />
        
        <select name="category_id">
        {% for cat in cats %}
                <option value="{{ cat.key.id }}"
                        {% ifequal item.category.key cat.key %}
                                selected = "selected"
                        {% endifequal %}
                        >
                        {{ cat.title }}
                </option>
        {% endfor %}
        </select>
        
        <div>Title:<br><input type="text" name="name" value="{{ item.name|escape }}" /></div>
        <div>Description:<br><textarea name="description" rows="3" cols="60">{{ item.description|escape }}</textarea></div>
        
        <div>Image file:<br><input type="file" name="image" /></div>
        
        <div><input type="submit" value="Ok"></div>
        <div><a href="/manage/portfolio">Отмена</a></div>
    </form>
{% endblock %}